package controller;

import java.util.ArrayList;

import manager.SectionMgr;
import entity.Course;
import entity.Section;

/**
 * @author huiwensong.2012, huangjm.2012
 * 
 */

public class SectionCtrl {

	private SectionMgr sectionMgr;

	public SectionCtrl() {
		sectionMgr = new SectionMgr();
	}

	public void addSection(Course course, String sectionCode, String dayOfWeek,
			String startTime, String endTime, String instructor, String venue,
			int size) {

		sectionMgr.addSection(new Section(course, sectionCode, dayOfWeek,
				startTime, endTime, instructor, venue, size));
	}

	public ArrayList<Section> retrieveSectionsForCourse(Course course) {
		return sectionMgr.retrieveSectionsForCourse(course.getCourseCode());
	}

	public void deleteAllSections() {
		sectionMgr.deleteAllSections();
	}

	public boolean hasSectionForCourse(String sectionCode, String courseCode) {
		ArrayList<Section> sections = sectionMgr
				.retrieveSectionsForCourse(courseCode);
		for (Section eachSection : sections) {
			if (eachSection.getSectionCode().equals(sectionCode)) {
				return true;
			}
		}
		return false;
	}
}
